import React, { Component } from "react";

export default class Controlled extends Component {
  constructor() {
    super();
    this.state = {
      value: "",
    };
  }
  render() {
    return (
      <div>
        <h2>受控组件</h2>
        <h2>{this.state.value}</h2>
        <input
          type="text"
          value={this.state.value}
          onChange={(e) => this.handleChangeValue(e)}
        />
      </div>
    );
  }
  handleChangeValue(e) {
    this.setState({
      value: e.target.value,
    });
  }
}
